Search
Other Articles Anywhere questions
Forum

Using {if} for custom fields

Dom Cassone's Avatar Dom Cassone
I have this structure and what is displayed is the code itself without the {article} {/article} :
{article}

{if application-specialist="Sara Taylor"}

Sara Taylor

386.366.5374

{else}

Application Specialist Unknown

{/if}

{/article}

What am I missing?
Thanks,
Dom
Peter van Westen's Avatar Peter van Westen ADMIN
Do you have this online so I can take a look?
Please post a rating at the Joomla! Extensions Directory
Andrea Malalana's Avatar Andrea Malalana ADMIN
Check the source code in the editor, that there's not any HTML character breaking your syntax.

For example stuff like:
{if application-specialist="Sara Taylor"}

Make sure the syntax is clean in the HTML mode of the editor as well.
Dom Cassone's Avatar Dom Cassone
Thank you for the quick answere!

Go to mytmm-dev.zacaw.com/dom-test

Andrea was correct, there was a &npsp; int the if statement, but while the code now executes, it does not display the proper output.

This is a very simplified version of what I need to do. There are 6 people that it can be, so I will need {if}{elseif}{/if} construct in the final version.

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
What output are you expecting? The article you are testing with has no custom field with name 'application-specialist'.
Please post a rating at the Joomla! Extensions Directory
Dom Cassone's Avatar Dom Cassone
Thank you for your reply.

I am looking to look at a custom user field.....am I wrong about what this extension can do.

You need to log in to the frontend as:

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
Articles Anywhere is about articles (as the name suggests).
The custom fields you can read out, concern custom fields attached to the article. It does not support checking custom fields of users.
Please post a rating at the Joomla! Extensions Directory
Dom Cassone's Avatar Dom Cassone
Thank you Peter.....I know that the extension was about articles, I just jumped to an invalid conclusion since I only use user custom fields and forgot about article custom fields....sorry.

Which of your extensions would be best for me to test user fields and display information depending on the value of a user custom field? I looked a Conditional Content, but could not find it there either.
Peter van Westen's Avatar Peter van Westen ADMIN
It can maybe be done with Conditional Content.
There is no ready-to-use assignment for this. So you would need to use the PHP assignment, and of course, figure out the necessary PHP code to collect the use custom fields.
Something like:
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$user_fields = FieldsHelper::getFields('com_users.user', JFactory::getUser(), true);
foreach($user_fields as $user_field) {
   if($user_field->name !== 'application-specialist') {
      continue;
   }
   return $user_field->value === 'Sara Taylor';
}
return false;
Which is a LOT of code for something relatively small 🤷🏻‍♂️
Please post a rating at the Joomla! Extensions Directory
Dom Cassone's Avatar Dom Cassone
Thank you so much for all your help....I am going to try to implement something similiar today.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription